namespace Statistics
{
    internal static class LogUtils
    {
        public static string CreateSendLog(object sender, string eventName, params object[] args)
        {
            var result = $"广播事件:{eventName} 发送者:{sender} ";
            if (args == null || args.Length <= 0)
                return result;

            result += CreateArgsLog(args);

            return result;
        }
        
        public static string CreateSendLog(object sender, string eventName, float timeMs, params object[] args)
        {
            var result = $"广播事件:{eventName} 发送者:{sender} 耗时:{timeMs} ";
            if (args == null || args.Length <= 0)
                return result;

            result += CreateArgsLog(args);

            return result;
        }

        public static string CreateListenLog(object listener, string eventName)
        {
            var result = $"监听事件:{eventName} 监听者:{listener}";
            return result;
        }

        private static string CreateArgsLog(object[] args)
        {
            var argsLog = "参数列表:[";
            for (var i = 0; i < args.Length; i++)
            {
                argsLog += $"{i}:{args[i]}";
                if (args.Length > 1 && i < args.Length - 1)
                    argsLog += ",";
            }
            argsLog += "]";
            return argsLog;
        }
    }
}